<?php

include_once "dao/timeattendanceDAO.php";

$requestType = $_GET['request'];



switch($requestType) {
	
	case "login" : if(($data = login($_POST['userid'], $_POST['password'])) !="") {
					$_SESSION['name'] = $data['name'];
					$_SESSION['role'] = $data['role'];
					$_SESSION['department'] = $data['department'];
					redirect($_GET['return'], "pass");
				   }
				   else {
				   	redirect($_GET['return'],"fail");
				   }	
		
		break;
		
	case "logout" : session_destroy();
					redirect($_GET['return'],"pass");
		break;
}




function redirect($url, $result) {
	?>
	<script type="text/javascript">window.location = "<?php echo $url."?result=".$result; ?>";</script>
	<?php 
}
?>